from QMemberType import QMemberType

class QMemberListEntry:
    def __init__(self,
                 teamID, teamName,
                 memberID, memberName,
                 currentMemberType, optionMemberType
                 ):
        self.TeamID = teamID
        # assign a default team name
        if not teamName:
            teamName = "Team %d"%(teamID)
        self.TeamName = teamName
        self.MemberID = memberID
        self.MemberName = memberName
        self.CurrentMemberType = currentMemberType
        self.OptionMemberType = optionMemberType

    def __repr__(self):
        ret = 'Team %d:"%s", Member %d:"%s": MemberType:Current= %s; Option= %s'%(
               self.TeamID,self.TeamName,
               self.MemberID,self.MemberName,
               self.CurrentMemberType, self.OptionMemberType)
        return ret

    def MemberSet(self, memName, memType):
        if memType in self.OptionMemberType:
            self.MemberName = memName
            self.CurrentMemberType = memType
            bSuccess = True
        else:
            bSuccess = False
        return bSuccess

    def MemberClear(self):
        bSuccess = self.MemberSet("", QMemberType.OPEN)
        return bSuccess
